<?php
/**
 * RedCross Application
 *
 * @copyright Copyright (c) 2010, Kristian Stokke Tryggestad, Rune Vikestad, Andreas Flaten Wist, Simen Nicolai Echholt, Ole Henrik Jahren
 */


class RedCross_View_Helper_ContentMenu extends Zend_View_Helper_Abstract
{
    private $_userNavigation;
    private $_adminNavigation;

	public function __construct()
	{
        $this->_userNavigation = Zend_Registry::get('mainNavigation');
        $this->_adminNavigation = Zend_Registry::get('adminNavigation');
	}

	public function contentMenu()
	{
        return $this;
	}

	public function renderMenu()
	{
	    $this->view->navigation()->menu()->setPartial('contentMenu.phtml');

	    $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
	    switch ($module) {
	        case 'core':
	            $navigation = $this->view->navigation()->menu()->renderPartial($this->_userNavigation);
	            break;
	        case 'admin':
	            $navigation = $this->view->navigation()->menu()->renderPartial($this->_adminNavigation);
	            break;
	    }

        return strlen($navigation) > 40 ? $navigation : '';
	}
}